package com.example.bob.service;


import com.example.bob.dao.ArticleMapper;
import com.example.bob.model.ArticleInfo;
import com.example.bob.model.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Resource
    private ArticleMapper articleMapper;


    //查询某个用户的所有文章
    public List<ArticleInfo> getListByUser(int uid){
        return articleMapper.getListByUser(uid);
    }


    //查询数据库中所有文章
    public List<ArticleInfo> getListByPage(int psize,int offset){
        return articleMapper.getListByPage(psize,offset);
    }

    //添加文章 ,默认返回受影响的行数
    public int add(ArticleInfo articleInfo){
        return articleMapper.add(articleInfo);
    }

    //删除文章
    public int del(ArticleInfo articleInfo){
        return articleMapper.del(articleInfo);
    }

    //根据文章id查询文章
    public ArticleInfo detail(int aid){
        return articleMapper.detail(aid);
    }

    //编辑更新文章
    public int updata(ArticleInfo articleInfo){
        return articleMapper.updata(articleInfo);
    }


    //获取文章总数量
    public int count(){
        return articleMapper.count();
    }

    //获取某篇文章的阅读量
    public int getReCount(int aid){
        return  articleMapper.getReCount(aid);
    }

    public void setReCount(int recount,int id){
        articleMapper.setReCount(recount,id);
    }

    public int artCount(int uid){

        return articleMapper.artCount(uid);
    }

}
